import {
  discussReplay
} from '../../../utils/api.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
   img:"",
   name:"",
   content:"",
   time:"",
   searchData:{
     token:"",
     active_id: "",
     content: "",
     puserid: "",
     pusername: "",
     puserimg: "",
     pcode:"",
     orderID:""
   }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onShow: function (options) {
    var that=this
    wx.getStorage({
      key: 'token',
      success: function (res) {
        let searchDataToken = "searchData.token";
        that.setData({
          [searchDataToken]: res.data
        })
      },
    })
    var data = JSON.parse(options.data)
    let searchDatapcode ="searchData.pcode"
    let searchDatapusername = "searchData.pusername"
    let searchDatapuserimg = "searchData.puserimg"
    let searchDatapuserid = "searchData.puserid"
    let searchDataactive_id = "searchData.active_id"
    let searchDataorderID = "searchData.orderID" 
    that.setData({
      img: data.puserimg,
      name: data.pusername,
      content: data.content,
      time: data.time,
      [searchDatapcode]: data.id,
      [searchDatapuserimg]: data.puserimg,
      [searchDatapusername]: data.pusername,
      [searchDatapuserid]: data.puserid,
      [searchDataactive_id]: data.active_id,
      [searchDataorderID]: data.orderID,
    })
  //  onsole.log("传来2", aa)
   // let data = JSON.parse(options.data)
  },
  //评论内容  
  titleBlur: function (e) {
    let searchDatacontent = "searchData.content"
    this.setData({
      [searchDatacontent]: e.detail.value
    })
  },
  //回复评论
  discussBtn() {
    discussReplay(this.data.searchData).then(res => {
      if (res.code == 126) {
        wx.showToast({
          title: res.msg,
          duration: 5000,
          success: function () {
            wx.switchTab({
              url: '../../personal/personal',
            })
          }
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },


  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})